$(document).ready(function(){
	/* 加载菜单  */
	initMenu();
});


var initMenu = function(){
	var data = {"p":"sys","m":"menuList","roleId":loginUserRoleId};
	var json = common.ajaxRequest( 'service' , data, 'GET');
	if( json && json.result == 0 )
    {
		var html='';
		var menuList = json.menuList;
		$(menuList).each(function(){
			if( this.level == 1 )
			{
				
				html+='<li class="level1" id="'+this.id+'">';
					html+='<a href="#">';
						html+='<i class="fa fa"></i>';
						html+='<span class="nav-label">'+this.name+'</span>';
						html+='<span class="fa arrow"></span>';
					html+=' </a>';
					html+=' <ul class="nav nav-second-level">';
					html+=' </ul>';
				html+=' </li>';
			}	
		});
		$('.indexPage').after(html);
		
		var menus = $('.level1');
		$(menus).each(function(inx,element){
			var menu = element;
			var id = $(menu).attr('id');
			var html='';
			$(menuList).each(function(){
				if( this.level == 2 && this.pId == id)
				{
					html+='<li><a class="J_menuItem" href="page?p=page/'+this.link+'">'+this.name+'</a></li>';
				}	
			});
			$(menu).find('ul').append(html);
		});
    }
	else
	{
		
	}	

};